package com.zp.self.kafka.entity;

import java.io.Serializable;

/**
 * 消息内容实体类
 * @author zyting
 * @sinne 2020-02-23
 */
public class MessageBody<T> implements Serializable {

    private static final long serialVersionUID = 343962578547375137L;

    private long msgId;   // 业务传递的消息id,用于跟踪消息情况与信息

    private long timestamp;  // 消息发送时间戳

    private T data;       // 消息内容

    // 如果二次开发人员没有设置msgId, 随机生成一个全局id
    public long getMsgId(){
        if(msgId == 0){
            msgId =1;
        }
        return msgId;
    }

    public void setMsgId(long msgId) {
        this.msgId = msgId;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }

    public void setData(T data) {
        this.data = data;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public T getData() {
        return data;
    }

}
